package com.ai.entity.made.page;

import cn.hutool.core.util.StrUtil;
import com.ai.entity.BasePage;
import com.ai.entity.made.ModbusServerInfo;
import com.ai.entity.made.OpcServerInfo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModelProperty;

/**
 * @Author jiaok
 * @Date 2024-11-26 16:58
 */
public class ModbusServerInfoPage extends BasePage<ModbusServerInfo> {

    @ApiModelProperty(value = "设备名称")
    private String deviceName;

    @ApiModelProperty(value = "ip")
    private String ip;

    @ApiModelProperty(value = "端口")
    private String port;

    @ApiModelProperty(value = "通信方式(1:TCP，2:RTU)")
    private String communicationModel;


    @Override
    public QueryWrapper<ModbusServerInfo> getQuery(QueryWrapper<ModbusServerInfo> queryWrapper) {
        return super.getQuery(queryWrapper)
                .eq(StrUtil.isNotBlank(communicationModel),"communication_model",communicationModel)
                .eq(StrUtil.isNotBlank(port),"port",port)
                .like(StrUtil.isNotBlank(ip),"ip",ip)
                .like(StrUtil.isNotBlank(deviceName),"device_name",deviceName)
                .orderByDesc("create_time");
    }
}
